//
//  UIViewController+Category.m
//  LCFN_Seller
//
//  Created by lcfn on 2018/8/9.
//  Copyright © 2018年 royce. All rights reserved.
//

#import "UIViewController+Category.h"

@implementation UIViewController (Category)
/**
 *  下拉刷新上啦加载
 */
- (void)setupRefresh:(UIScrollView *)tableView
{
    // 设置回调（一旦进入刷新状态，就调用target的action，也就是调用self的loadNewData方法）
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRereshing)];
    // 设置自动切换透明度(在导航栏下面自动隐藏)
    header.automaticallyChangeAlpha = YES;
    // 隐藏时间
    header.lastUpdatedTimeLabel.hidden = NO;
    // 设置header
    tableView.mj_header = header;
    
    tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRereshing)];
    // 设置了底部inset
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    // 忽略掉底部inset
    tableView.mj_footer.ignoredScrollViewContentInsetBottom = 0;
}
//下拉刷新
- (void)setUpHeaderRefresh:(UIScrollView *)tableView
{
    // 设置回调（一旦进入刷新状态，就调用target的action，也就是调用self的loadNewData方法）
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRereshing)];
    // 设置自动切换透明度(在导航栏下面自动隐藏)
    header.automaticallyChangeAlpha = YES;
    // 隐藏时间
    header.lastUpdatedTimeLabel.hidden = NO;
    // 设置header
    tableView.mj_header = header;
    // 设置了底部inset
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
//上拉加载
- (void)setUpFooterRefresh:(UIScrollView *)tableView
{
    tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRereshing)];
    // 设置了底部inset
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    // 忽略掉底部inset
    tableView.mj_footer.ignoredScrollViewContentInsetBottom = 0;
}
- (void)headerRereshing
{
}
- (void)footerRereshing
{
}
- (void)headerEnd:(UIScrollView *)tableView
{
    [tableView.mj_header endRefreshing];
}
- (void)footerEnd:(UIScrollView *)tableView
{
    [tableView.mj_footer endRefreshing];
}
-(void)footerNoMoreData:(UIScrollView *)tableView{
    tableView.mj_footer.state = MJRefreshStateNoMoreData;
}
@end
